<?php

namespace app\command;

use app\admin\model\Channel;
use app\admin\model\Custom;
use app\admin\model\hotel\Hotel;
use app\admin\model\Maint;
use app\admin\model\Member;
use app\admin\model\Other;
use app\admin\model\Project;
use app\admin\model\ProjectModel;
use app\admin\model\Scenic;
use app\admin\model\Taobao;
use app\api\model\HotelOrder;
use app\api\model\MemberVipCard;
use app\api\model\ScenicOrder;
use app\api\model\VipOrder;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class Statistics extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('Statistics');
        // 设置参数
        $this->setDescription('数据统计')->setHelp("php think Statistics");
    }

    protected function execute(Input $input, Output $output)
    {
        $output->writeln('开始执行');
        $data['scenic_count'] = (new Scenic())->where(['status' => 1])->count();
        $data['hotel_count'] = (new Hotel())->where(['status' => 1])->count();
        $data['member_count'] = (new Member())->count();

        //交易数据
        $data['scenic_order_count'] = (new ScenicOrder())->where(['status' => [1,2,3,4]])->count();
        $data['hotel_order_count'] = (new HotelOrder())->where(['status' => [1,2,3,4]])->count();
        $data['vip_order_count']  = (new VipOrder())->where(['status' => 1])->count();

        //收益数据
        $data['vip_recharge_count'] = (new VipOrder())->where(['status'=>1])->sum('price');

        $data['scenic_check_num']  = (new ScenicOrder())->where(['status' => 1])->count();
        $data['hotel_check_num']  = (new HotelOrder())->where(['status' => 1])->count();


        $data['update_time'] = time();

        (new \app\admin\model\Statistics())->where(['id' => 1])->update($data);


        $output->writeln('结束执行');

    }
}